package com.michaelliu.study.viewpager2

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.michaelliu.study.viewpager2.fragment.PageFragmentA
import com.michaelliu.study.viewpager2.fragment.PageFragmentB
import com.michaelliu.study.viewpager2.fragment.PageFragmentC

class ViewPagerAdapter(fa : FragmentActivity) : FragmentStateAdapter(fa) {
    override fun getItemCount(): Int {
        return 3
    }

    override fun createFragment(position: Int): Fragment {
        when(position) {
            0 -> {
                return PageFragmentA()
            }

            1 -> {
                return PageFragmentB()
            }

            2 -> {
                return PageFragmentC()
            }
            else -> {
                return PageFragmentA()
            }
        }
    }
}